#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;
use lib 'tests/search';
use AIR2TestUtils;    # sets lib path
use AIR2::Searcher::Responses;
use Data::Dump qw( dump );
use JSON::XS;
use utf8;

SKIP: {

    if ( !AIR2TestUtils::search_env_ok() ) {
        skip "The search env does not look sane. Skipping all tests", 4; 
    }

    my $ellips = "…";
    my $authz = AIR2TestUtils::dummy_authz();

    ok( my $searcher = AIR2::Searcher::Responses->new(), "new searcher" );

    #dump( $searcher );
    ok( my $results = $searcher->do_search(
            {   q        => 'garden al-jboury',
                auth_tkt => $authz,
            }
        ),
        "get results"
    );
    ok( my $summary = $results->{results}->[0]->{summary}, "get summary" );

    #dump( $results->{results} );
    #print STDERR $summary;
    #diag($summary);
    #diag( $results->{results}->[0]->{id} );

    like( $summary, qr/$ellips/, "matches utf8 character" );

}
